#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace std;

const char OK_MESSAGE[] = "ok! Brackets combination is valid.";
const char ERROR_MESSAGE[] = "Error! Brackets combination is invalid!";

int main() {
    cout << "Enter the brackets combination: " << endl;
    string s;
    cin >> s;
    cout << endl;

    vector<char> v;
    for (string::const_iterator iter = s.begin(), end = s.end(); iter != end; ++iter) {
        const char &ch = *iter;
        if (ch != ')' && ch != '(')
            continue;

        if (ch == '(') {
            v.push_back(ch);
        } else {
            if (v.empty() || v.back() != '(') {
                cout << ERROR_MESSAGE << endl;
                return 0;
            } else {
                v.pop_back();
            }
        }
    }

    cout << (v.empty() ? OK_MESSAGE : ERROR_MESSAGE) << endl;
    return 0;
}
